<?php

function print_observation_form() {
  $gender_options = array(t('Male'), t('Female'), t('Hermaphrodite'), t('Not Applicable'));
  $tod_options = array(
                  t('Early Dawn'), 
                  t('Dawn(Before Sunrise)'), 
                  t('Morning Twilight'),
                  t('Daybreak'), 
                  t('Early Morning'), 
                  t('Morning'), 
                  t('Late Morning'),
                  t('Noon'), 
                  t('Early Afternoon'), 
                  t('Evening Twilight'), 
                  t('Dusk(Sunset)'),
                  t('Early Evening'), 
                  t('Evening'), 
                  t('Late Evening'), 
                  t('Night'),
                  t('Mid Night'), 
                  t('Late Night')
                );

  $countries_list = get_countries_list();
?>
<form action="<?php print base_path() . 'observation/submit'; ?>"  accept-charset="UTF-8" method="post" id="win-getObservations" style="display:none;">
  <div>
    <fieldset class=" collapsible">
      <legend><?php print t('Common Names'); ?></legend>
      <fieldset class=" collapsible">
        <legend><?php print t('Common Name'); ?></legend>
        <div class="form-item" id="edit-wo-common-name-wrapper">
          <label for="edit-wo-common-name">
            <?php print t('Name'); ?>: <span class="form-required" title="<?php print t('This field is required.'); ?>">*</span>
          </label>
          <input type="text" maxlength="128" name="wo_common_name" id="edit-wo-common-name" size="30" value="" class="form-text required" />
          <div class="description"><?php print t('Enter common name.'); ?></div>
        </div>

        <div class="form-item" id="edit-wo-common-name-language-wrapper">
          <label for="edit-wo-common-name-language"><?php print t('Language'); ?>: </label>
          <input type="text" maxlength="128" name="wo_common_name_language" id="edit-wo-common-name-language" size="30" value="" class="form-text" />
          <div class="description"><?php print t('Enter the language of the common name.'); ?></div>
        </div>

        <div class="form-item" id="edit-wo-common-name-region-wrapper">
          <label for="edit-wo-common-name-region"><?php print t('Region'); ?>: </label>
          <input type="text" maxlength="128" name="wo_common_name_region" id="edit-wo-common-name-region" size="30" value="" class="form-text" />
          <div class="description"><?php print t('Enter the region where the common name is used.'); ?></div>
        </div>
      </fieldset>

      <input id="btn_add_more_common_names" type="button" value="Add more common names" onclick="addMoreCommonNamesUI()" />
    </fieldset>

    <fieldset class=" collapsible collapsed"><legend><?php print t('Scientific Information'); ?></legend>
      <div class="form-item" id="edit-wo-taxa-wrapper">
        <label for="edit-wo-taxa"><?php print t('Taxa'); ?>: </label>
        <input type="text" maxlength="128" name="wo_taxa" id="edit-wo-taxa" size="40" value="" class="form-text" />
        <div class="description"><?php print t('Enter taxa.'); ?></div>
      </div>

      <div class="form-item" id="edit-wo-kingdom-wrapper">
        <label for="edit-wo-kingdom"><?php print t('Kingdom: '); ?></label>
        <input type="text" maxlength="128" name="wo_kingdom" id="edit-wo-kingdom" size="40" value="" class="form-text" />
        <div class="description"><?php print t('Enter Kingdom.'); ?></div>
      </div>

      <div class="form-item" id="edit-wo-phylum-wrapper">
        <label for="edit-wo-phylum"><?php print t('Phylum'); ?>: </label>
        <input type="text" maxlength="128" name="wo_phylum" id="edit-wo-phylum" size="40" value="" class="form-text" />
        <div class="description"><?php print t('Enter phylum.'); ?></div>
      </div>

      <div class="form-item" id="edit-wo-class-wrapper">
        <label for="edit-wo-class"><?php print t('Class'); ?>: </label>
        <input type="text" maxlength="128" name="wo_class" id="edit-wo-class" size="40" value="" class="form-text" />
        <div class="description"><?php print t('Enter class.'); ?></div>
      </div>

      <div class="form-item" id="edit-wo-order-wrapper">
        <label for="edit-wo-order"><?php print t('Order'); ?>: </label>
        <input type="text" maxlength="128" name="wo_order" id="edit-wo-order" size="40" value="" class="form-text" />
        <div class="description"><?php print t('Enter order.'); ?></div>
      </div>

      <div class="form-item" id="edit-wo-family-wrapper">
        <label for="edit-wo-family"><?php print t('Family'); ?>: </label>
        <input type="text" maxlength="128" name="wo_family" id="edit-wo-family" size="40" value="" class="form-text" />
        <div class="description"><?php print t('Enter family.'); ?></div>
      </div>

      <div class="form-item" id="edit-wo-genus-wrapper">
        <label for="edit-wo-genus"><?php print t('Genus'); ?>: </label>
        <input type="text" maxlength="128" name="wo_genus" id="edit-wo-genus" size="40" value="" class="form-text" />
        <div class="description"><?php print t('Enter genus.'); ?></div>
      </div>

      <div class="form-item" id="edit-wo-species-wrapper">
        <label for="edit-wo-species"><?php print t('Species'); ?>: </label>
        <input type="text" maxlength="128" name="wo_species" id="edit-wo-species" size="40" value="" class="form-text" />
        <div class="description"><?php print t('Enter species.'); ?></div>
      </div>
    </fieldset>

    <div class="form-item" id="edit-wo-gender-wrapper">
      <label for="edit-wo-gender"><?php print t('Gender'); ?>: </label>
      <select name="wo_gender" class="form-select" id="edit-wo-gender" >
        <?php print createDropdownOptions($gender_options); ?>
      </select>
      <div class="description"><?php print t('Please select the gender of specimen.'); ?></div>
    </div>

    <div class="form-item" id="edit-wo-num-individuals-wrapper">
      <label for="edit-wo-num-individuals"><?php print t('Number of Individuals'); ?>: </label>
      <input type="text" maxlength="128" name="wo_num_individuals" id="edit-wo-num-individuals" size="10" value="" class="form-text" />
      <div class="description"><?php print t('Enter number of individuals observed.'); ?></div>
    </div>

    <div class="form-item" id="edit-wo-on-date-wrapper">
      <label for="edit-wo-on-date"><?php print t('Date'); ?>: <span class="form-required" title="This field is required.">*</span></label>
      <input type="text" maxlength="128" name="wo_on_date" id="edit-wo-on-date" size="10" value="" class="form-text required datepicker" disabled="disabled" />
      <div class="description"><?php print t('Enter observation date.'); ?></div>
    </div>

    <fieldset class=" collapsible">
      <legend><?php print t('Time'); ?></legend>
      <div class="form-item" id="edit-wo-know-exact-time-wrapper">
        <label class="option" for="edit-wo-know-exact-time">
          <input type="checkbox" name="wo_know_exact_time" id="edit-wo-know-exact-time" value="1" onclick="toggleExactTime(this.checked)" class="form-checkbox" />
          <?php print t('Know exact time.'); ?>
        </label>
      </div>

      <div class="form-item" id="edit-wo-exact-time-wrapper">
        <label for="edit-wo-exact-time"><?php print t('Exact Time'); ?>: </label>
        <div class="container-inline">
          <div class="form-item" id="edit-wo-exact-time-hour-wrapper">
            <select name="wo_exact_time[hour]" class="form-select" id="edit-wo-exact-time-hour" >
              <!--<option value="1">01</option><option value="2">02</option><option value="3">03</option><option value="4">04</option><option value="5" selected="selected">05</option><option value="6">06</option><option value="7">07</option><option value="8">08</option><option value="9">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option>-->
            </select>
          </div>

          <div class="form-item" id="edit-wo-exact-time-minute-wrapper">
            <select name="wo_exact_time[minute]" class="form-select" id="edit-wo-exact-time-minute" >
              <!--<option value="0">00</option><option value="1">01</option><option value="2">02</option><option value="3">03</option><option value="4">04</option><option value="5">05</option><option value="6">06</option><option value="7">07</option><option value="8">08</option><option value="9">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option><option value="31">31</option><option value="32">32</option><option value="33">33</option><option value="34">34</option><option value="35">35</option><option value="36">36</option><option value="37">37</option><option value="38">38</option><option value="39" selected="selected">39</option><option value="40">40</option><option value="41">41</option><option value="42">42</option><option value="43">43</option><option value="44">44</option><option value="45">45</option><option value="46">46</option><option value="47">47</option><option value="48">48</option><option value="49">49</option><option value="50">50</option><option value="51">51</option><option value="52">52</option><option value="53">53</option><option value="54">54</option><option value="55">55</option><option value="56">56</option><option value="57">57</option><option value="58">58</option><option value="59">59</option>-->
            </select>
          </div>

          <div class="form-item" id="edit-wo-exact-time-meridiem-wrapper">
            <select name="wo_exact_time[meridiem]" class="form-select" id="edit-wo-exact-time-meridiem" >
              <option value="am"><?php print t('am'); ?></option>
              <option value="pm"><?php print t('pm'); ?></option>
            </select>
          </div>
        </div>
        <div class="description"><?php print t('Enter observation time.'); ?></div>
      </div>

      <div class="form-item" id="edit-wo-time-of-day-wrapper">
        <label for="edit-wo-time-of-day"><?php print t('Time of Day'); ?>: </label>
        <select name="wo_time_of_day[]" multiple="multiple"  class="form-select" id="edit-wo-time-of-day"  size="5">
          <?php print createDropdownOptions($tod_options); ?>
        </select>
        <div class="description"><?php print t('Please select the observation time of day. You can select multiple options by pressing Ctrl key.'); ?></div>
      </div>
    </fieldset>

    <fieldset class=" collapsible">
      <legend><?php print t('Positional Level Parameters'); ?></legend>
      <div class="form-item" id="edit-wo-altitude-wrapper">
        <label for="edit-wo-altitude"><?php print t('Altitude'); ?>: </label>
        <input type="text" maxlength="20" name="wo_altitude" id="edit-wo-altitude" size="60" value="" class="form-text" />
        <div class="description"><?php print t('Enter altitude in meters.'); ?></div>
      </div>

      <div class="form-item" id="edit-wo-depth-wrapper">
        <label for="edit-wo-depth"><?php print t('Depth'); ?>: </label>
        <input type="text" maxlength="20" name="wo_depth" id="edit-wo-depth" size="60" value="" class="form-text" />
        <div class="description"><?php print t('Enter depth in meters.'); ?></div>
      </div>
    </fieldset>
    
    <fieldset class=" collapsible">
      <legend><?php print t('Location Information'); ?></legend>
      <div class="form-item" id="edit-wo-country-wrapper">
        <label for="edit-wo-country"><?php print t('Country'); ?>: </label>
        <select name="wo_country" onchange="getRegionsForCountry(parseInt(this.value))" class="form-select" id="edit-wo-country" >
          <?php print createDropdownOptions($countries_list); ?>
        </select>
        <div class="description"><?php print t('Please select the country of observation.'); ?></div>
      </div>
      
      <div class="form-item" id="edit-wo-region-wrapper">
        <label for="edit-wo-region"><?php print t('Region/ State'); ?>: </label>
        <select name="wo_region" onchange="getCitiesForRegion(parseInt(this.value))" class="form-select" id="edit-wo-region" >
        </select>
        <div class="description"><?php print t('Please select the region/ state of observation.'); ?></div>
      </div>
      
      <div class="form-item" id="edit-wo-city-wrapper">
        <label for="edit-wo-city"><?php print t('City'); ?>: </label>
        <select name="wo_city" class="form-select" id="edit-wo-city" >
        </select>
        <div class="description"><?php print t('Please select the city of observation.'); ?></div>
      </div>
      
      <div class="form-item" id="edit-wo-locality-wrapper">
        <label for="edit-wo-locality"><?php print t('Locality'); ?>: </label>
        <input type="text" maxlength="50" name="wo_locality" id="edit-wo-locality" size="60" value="" class="form-text" />
        <div class="description"><?php print t('Enter the locality.'); ?></div>
      </div>
    </fieldset>

    <fieldset class=" collapsible">
      <legend><?php print t('Waterbody Information'); ?></legend>
      <div class="form-item" id="edit-wo-haswaterbody-wrapper">
        <label class="option" for="edit-wo-haswaterbody">
          <input type="checkbox" name="wo_haswaterbody" id="edit-wo-haswaterbody" value="1" onclick="toggleWaterbodyInfo(this.checked)" class="form-checkbox" />
          <?php print t('Is any waterbody related to the observation.'); ?>
        </label>
      </div>
      <div class="form-item" id="edit-wo-waterbody-types-wrapper">
        <label for="edit-wo-waterbody-types"><?php print t('Waterbody Type'); ?>: </label>
        <select name="wo_waterbody_types" class="form-select" id="edit-wo-waterbody-types" >
          <!--
          <option value="0" selected="selected">Lake</option>
          <option value="1">River</option>
          <option value="2">Ocean</option>
          -->
        </select>
        <div class="description"><?php print t('Please select the waterbody type.'); ?></div>
      </div>
      <div class="form-item" id="edit-wo-waterbody-name-wrapper">
        <label for="edit-wo-waterbody-name"><?php print t('Waterbody Name'); ?>: </label>
        <input type="text" maxlength="50" name="wo_waterbody_name" id="edit-wo-waterbody-name" size="60" value="" class="form-text" />
        <div class="description"><?php print t('Enter the waterbody name.'); ?></div>
      </div>
    </fieldset>

    <fieldset class=" collapsible">
      <legend><?php print t('Observer Information'); ?></legend>
      <div class="form-item">
        <label><?php print t('Observer'); ?>: </label>
        <div class="form-radios"><div class="form-item" id="edit-wo-radio-observer-0-wrapper">
          <label class="option" for="edit-wo-radio-observer-0">
            <input type="radio" id="edit-wo-radio-observer-0" name="wo_radio_observer" value="0"  checked="checked"  onclick="toggleOtherObserverDetails(parseInt(this.value))" class="form-radio" />
            <?php print t('Self'); ?>
          </label>
          </div>
          <div class="form-item" id="edit-wo-radio-observer-1-wrapper">
            <label class="option" for="edit-wo-radio-observer-1">
              <input type="radio" id="edit-wo-radio-observer-1" name="wo_radio_observer" value="1"   onclick="toggleOtherObserverDetails(parseInt(this.value))" class="form-radio" />
              <?php print t('Other'); ?>
            </label>
          </div>
        </div>
      </div>
      
      <fieldset id="fieldset_other_observer" class=" collapsible">
        <legend><?php print t('Other Observers'); ?></legend>
        <div class="form-item" id="edit-wo-select-other-observer-wrapper">
          <label for="edit-wo-select-other-observer"><?php print t('Observer'); ?>: </label>
          <select name="wo_select_other_observer" onchange="getOtherObserverDetails(parseInt(this.value))" class="form-select" id="edit-wo-select-other-observer" ><option value="0" selected="selected">New</option><option value="1">Observer 1</option><option value="2">Observer 2</option><option value="3">Observer 3</option></select>
          <div class="description"><?php print t('Please select an observer. To enter new observer details, select new.'); ?></div>
        </div>
        
        <div class="form-item" id="edit-wo-other-observer-first-name-wrapper">
          <label for="edit-wo-other-observer-first-name"><?php print t('First Name'); ?>: <span class="form-required" title="This field is required.">*</span></label>
          <input type="text" maxlength="50" name="wo_other_observer_first_name" id="edit-wo-other-observer-first-name" size="60" value="" class="form-text required" />
          <div class="description"><?php print t('Enter the first name.'); ?></div>
        </div>

        <div class="form-item" id="edit-wo-other-observer-last-name-wrapper">
          <label for="edit-wo-other-observer-last-name"><?php print t('Last Name'); ?>: <span class="form-required" title="This field is required.">*</span></label>
          <input type="text" maxlength="50" name="wo_other_observer_last_name" id="edit-wo-other-observer-last-name" size="60" value="" class="form-text required" />
          <div class="description"><?php print t('Enter the last name.'); ?></div>
        </div>

        <div class="form-item" id="edit-wo-other-observer-email-id-wrapper">
          <label for="edit-wo-other-observer-email-id"><?php print t('Email ID'); ?>: </label>
          <input type="text" maxlength="50" name="wo_other_observer_email_id" id="edit-wo-other-observer-email-id" size="60" value="" class="form-text" />
          <div class="description"><?php print t('Enter the email ID.'); ?></div>
        </div>

        <div class="form-item" id="edit-wo-other-observer-address-wrapper">
          <label for="edit-wo-other-observer-address"><?php print t('Postal Address'); ?>: </label>
          <textarea cols="60" rows="5" name="wo_other_observer_address" id="edit-wo-other-observer-address"  class="form-textarea resizable"></textarea>
          <div class="description"><?php print t('Enter the address.'); ?></div>
        </div>

        <div class="form-item" id="edit-wo-other-observer-phone-number-wrapper">
          <label for="edit-wo-other-observer-phone-number"><?php print t('Phone number'); ?>: </label>
          <input type="text" maxlength="20" name="wo_other_observer_phone_number" id="edit-wo-other-observer-phone-number" size="60" value="" class="form-text" />
          <div class="description"><?php print t('Enter the phone number.'); ?></div>
        </div>

        <div class="form-item" id="edit-wo-other-observer-mobile-wrapper">
          <label for="edit-wo-other-observer-mobile"><?php print t('Mobile Number'); ?>: <span class="form-required" title="This field is required.">*</span></label>
          <input type="text" maxlength="20" name="wo_other_observer_mobile" id="edit-wo-other-observer-mobile" size="60" value="" class="form-text required" />
          <div class="description"><?php print t('Enter the cell number.'); ?></div>
        </div>
      </fieldset>
    </fieldset>

    <div class="form-item" id="edit-wo-comments-wrapper">
      <label for="edit-wo-comments"><?php print t('Comments'); ?>: </label>
      <textarea cols="60" rows="5" name="wo_comments" id="edit-wo-comments"  class="form-textarea resizable"></textarea>
      <div class="description"><?php print t('Enter comments.'); ?></div>
    </div>
    
    <input type="submit" name="op" id="edit-wo-submit" value="Submit"  class="form-submit" />
  </div>

  <input type="hidden" name="wo_topology" id="edit-wo-topology" value=""  />

</form>
<?php
}

function createDropdownOptions($arr) {
  $options = '';
  if (count($arr) > 0) {
    foreach ($arr as $id => $name) {
      $options .= '<option value="'.$id.'">'.t($name).'</option>';
    }
  }
  return $options;
}